<template>
  <view class="page-total">
    <view class="tab-list">
      <view class="list" v-for="(item,index) in TabBarList" @click="onTabBar(item,index)"
      :style="{marginTop: (item.th) ?  '-18rpx' : '0rpx'}" :key="index">
      <!-- <image class="img" :src="item.selectedIconPath" v-if="jumpType == 'dashui'"></image> -->
        <image :class="{waterImg:item.currentIndex ==='dashui'}" :src="item.selectedIconPath" v-show="jumpType == item.currentIndex" :style="{width: item.th ?  '98rpx' : '46rpx',height: item.th ?  '64rpx' : '46rpx',borderRadius: item.th ?  '12rpx' : '0rpx'}">
        </image>
        <image class="img" :class="{waterImg:item.currentIndex ==='dashui'}"  :src="item.iconPath" v-show="jumpType != item.currentIndex" :style="{width: item.th ?  '98rpx' : '46rpx',height: item.th ?  '64rpx' : '46rpx',borderRadius: item.th ?  '12rpx' : '0rpx'}">
        </image>
        <text :class="['text',{'action':jumpType==item.currentIndex}]" :style="{marginTop:item.th ?  '4rpx' : '0rpx'}">{{ item.text }}
        </text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      TabBarList: [],
      codeheight: 0,
      isOverall: 0,
      phoneModel: '',
      imgDm: '',
    };
  },
  props: {
    jumpType: {
      type: String,
      default: '',
    }
  },
  computed: {},
  onShow() {

  },
  created() {
    this.tabList()
    const basicConfig = uni.getStorageSync('BASIC_CONFIG');
    const page_foot = basicConfig.page_foot
    const water_role = uni.getStorageSync('USER_INFO_ROLE');
    const tabBarItems = page_foot[water_role] ??[]
    this.TabBarList =tabBarItems;
  },
  onReady() {

  },
  mounted() {
    try {
      const res = uni.getSystemInfoSync();
      let that = this;
      // 获取系统信息
      uni.getSystemInfo({
        success(res) {
          that.codeheight = Math.round(res.screenHeight);
          that.phoneModel = res.model
        }
      });
    } catch (e) {
      // error
    }
  },
  methods: {
    tabList(){

    },
    switchTab(url) {
      uni.switchTab({
        url: url
      })
    },
    getIndex() {
      let pagesList = getCurrentPages()
      if (pagesList.length == 0) {
        this.tabIndex = 0
      } else {
        let page = pagesList[pagesList.length - 1].route
        this.TabBarList.forEach((item, index) => {
          if (item.path != undefined && item.path != null && item.path != '') {
            if (item.path.indexOf(page) !== -1) {
              this.tabIndex = index
            }
          }
        })
      }
      return this.tabIndex
    },
    /**
     * @param {Object} item
     * @param {Number} index
     */
    onTabBar(item, index) {
      uni.switchTab({
        url: item.pagePath
      })
    },
    setTabbarCouont(index, count) {
      this.$set(this.TabBarList[index], 'count', count);
    },
  }
}
</script>

<style scoped lang="scss">
@import 'myTabbar.scss';
</style>
